//
//  Stack.m
//  iOSAlgorithmOC
//
//  Created by Mr.Wei on 2021/3/15.
//

#import "Stack.h"
@interface Stack<__covariant ObjectType>()
@property (nonatomic,copy)NSMutableArray<ObjectType> *stackArray;
@end
@implementation Stack
- (instancetype)init
{
    self = [super init];
    if (self) {
        self.stackArray = [[NSMutableArray alloc]init];
    }
    return self;
}


- (BOOL)isEmpty{
    return self.stackArray.count == 0;
}
- (NSInteger)count{
    return self.stackArray.count;
}
- (void)push:(id)element{
    [self.stackArray addObject:element];
}
- (id)pop{
    id a = self.stackArray.lastObject;
    [self.stackArray removeLastObject];
    return a;
}
- (id)top{
    return self.stackArray.lastObject;
}
@end
